package thread;

public class ThreadDemo1 {
    public static void main(String[] args) {
        //创建线程1
        MyThread t1 = new MyThread();
        t1.setName("线程1");
        t1.start();//启动线程1

        //创建线程2
        MyThread t2 = new MyThread();
        t2.setName("线程2");
        t2.start();//启动线程2

        //创建线程3
        MyThread t3 = new MyThread();
        t3.setName("线程3");
        t3.start();//启动线程3
    }
}
//创建一个类继承线程类
class MyThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + ":\n\t" +i);
        }
    }
}
